;; Exercises of 2.3 Symbolic Data

;; Exercise 2.53
(list 'a 'b 'c)				; (a b c)
(list (list 'george))			; ((george))
(cdr '((x1 x2) (y1 y2)))		; ((y1 y2))
(cadr '((x1 x2) (y1 y2)))		; (y1 y2)
(pair? (car '(a short list)))		; false
(memq 'red '((red shoes) (blue socks)))	; false
(memq 'red '(red shoes blue socks))	; (red shoes blue socks)

;; Exercise 2.54
(define (equal? a b)
  (cond ((and (null? a) (null? b)) true)
	((or (null? a) (null? b)) false)
	((and (symbol? (car a)) 
	      (symbol? (car b)))
          (eq? (car a) (car b)))
	((and (pair? (car a)) (pair? (car b))) 
	 (and (equal? (car a) (car b))
	      (equal? (cdr a) (cdr b))))))
    
(equal? '(this is a list) '(this is a list)) ; true
(equal? '(this is a list) '(this (is a) list)) ; false

(equal? '() '())			; #t
(equal? '(a) '(a))			; #t
(equal? '() '(b))			; #t
(equal? '(a (b)) '(a b))		; #t


;; Exercise 2.55
(car ''abracadabra)			; 'abracadabra
;; 在Scheme执行时, 会把'替换成quote, 因此上述式子等价于
;; (car (quote (quote abracadabra)))
;; 因此返回quote

;; Exercise 2.56

